from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from .api import upload, ocr, process, download
from .utils.logger import setup_logger

# 创建日志记录器
logger = setup_logger('main')

# 创建FastAPI应用
app = FastAPI(
    title="PDF OCR处理系统",
    description="支持PDF文件上传、OCR识别、文本处理和下载的API系统",
    version="1.0.0"
)

# 配置CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 注册路由
app.include_router(upload.router, prefix="/api", tags=["上传"])
app.include_router(ocr.router, prefix="/api", tags=["OCR"])
app.include_router(process.router, prefix="/api", tags=["处理"])
app.include_router(download.router, prefix="/api", tags=["下载"])

@app.get("/")
async def root():
    """根路径接口"""
    return {"message": "PDF OCR处理系统API"} 